﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/style.css" />
<title>商品列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 商家管理 <span class="c-gray en">&gt;</span> 商品列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" id="refresh"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form action="<?php echo url('goods/goodsList')?>" method="get">
		<div class="text-c">创建时间：
			<input type="text" name="startTime" value="<?php echo isset($display['startTime']) ? $display['startTime'] : ''?>" onfocus="WdatePicker()" id="datemin" class="input-text Wdate" style="width:120px;">
			至
			<input type="text" name="endTime" value="<?php echo isset($display['endTime']) ? $display['endTime'] : ''?>"   onfocus="WdatePicker()" id="datemax" class="input-text Wdate" style="width:120px;">
			<input type="text" name="searchName" value="<?php echo isset($display['searchName']) ? $display['searchName'] : ''?>" class="input-text" style="width:250px" placeholder="输入编号" id="" >
            <select class="select-box" style="width: 90px;padding: 5px 5px;" name="type_id" size="1">
                <option value="">商品类型</option>
                <?php foreach($type as $v):?>
                <option value="<?php echo $v['id']?>" <?php if(isset($display['type_id']) && $display['type_id'] == $v['id']) echo 'selected';?>><?php echo $v['name']?></option>
                <?php endforeach; ?>
            </select>
            <select class="select-box" style="width: 70px;padding: 5px 5px;" size="1" name="status">
				<option value="" selected>状态</option>
				<option value="0" <?php if(isset($display['status']) && $display['status'] == 0) echo 'selected';?>>待审核</option>
				<option value="1" <?php if(isset($display['status']) && $display['status'] == 1) echo 'selected';?>>未通过</option>
				<option value="2" <?php if(isset($display['status']) && $display['status'] == 2) echo 'selected';?>>已禁用</option>
				<option value="3" <?php if(isset($display['status']) && $display['status'] == 3) echo 'selected';?>>已启用</option>
				<option value="4" <?php if(isset($display['status']) && $display['status'] == 4) echo 'selected';?>>已售完</option>
			</select>
			<button type="submit" class="btn btn-success radius"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
		</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="show('添加商品','<?php echo url('goods/goodsAdd')?>','','')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加商品</a>
		</span>
	</div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort mt-10">
		<thead>
			<tr class="text-c">
				<th width="40">ID</th>
				<th width="120">商品编号</th>
                <th width="100">图片</th>
				<th width="150">商品名称</th>
                <th width="300">描述</th>
                <th width="100">商品类型</th>
				<th width="120" <?php if($flag || $display['bid']) echo 'hidden';?>>所属商家</th>
				<th width="70" <?php if($flag) echo 'hidden';?>>进价(￥)</th>
				<th width="70">单价(￥)</th>
				<th width="120">创建时间</th>
				<th width="60">状态</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
		<?php foreach($list as $v):?>
			<tr class="text-c">
				<td><?php echo $v['id']?></td>
				<td><?php echo $v['goods_no']?></td>
                <td><img src="<?php echo $pre.$v['image']?>" width="100" height="60" class="ml-5"></td>
                <td><?php echo $v['name'];?></td>
                <td><?php echo $v['descrip'];?></td>
                <td><?php echo $v['type_name'];?></td>
                <td <?php if($flag || $display['bid']) echo 'hidden';?>><u style="cursor:pointer" class="text-primary" onclick="show('商家详情','<?php echo url('business/businessShow',array('id' => $v['bid']))?>','','1200','')">
                    <?php echo $v['business']?>(<?php echo $v['bid']?>)</u></td>
                <td><?php echo empty($v['bprice']) ? '-' : sprintf('%.2f',$v['bprice']);?></td>
                <td <?php if($flag) echo 'hidden';?>><?php echo empty($v['price']) ? '-' : sprintf('%.2f',$v['price']);?></td>
                <td><?php echo empty($v['create_time']) ? '-' : date('Y-m-d H:i:s',$v['create_time'])?></td>
                <td class="td-status"><span class="label <?php echo empty($v['status']) ? 'label-secondary' : ($v['status'] == 1 ? 'label-warning' : ($v['status'] == 2 ? 'label-defaunt' : ($v['status'] == 3 ? 'label-success' : 'label-danger')));?> radius">
                    <?php echo empty($v['status']) ? '待审核' : ($v['status'] == 1 ? '未通过' : ($v['status'] == 2 ? '已禁用' : ($v['status'] == 3 ? '已启用' : '已售完')))?></span></td>
                <td class="td-manage">
					<?php if($v['status'] == 0 && !$flag){?>
                    <a class="ml-5" id="pass" href="javascript:;" title="审核通过" onclick="pass(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e1;</i></a>
                    <a class="ml-5" id="nopass" href="javascript:;" title="审核拒绝" onclick="nopass(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6dd;</i></a>
                    <?php } if($v['status'] == 2) {?>
                    <a href="javascript:;" title="启用" onclick="start(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe605;</i></a>
                    <?php } if($v['status'] == 3) {?>
                    <a href="javascript:;" title="禁用" onclick="stop(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe60e;</i></a>
                    <?php } if($v['status'] == 4) {?>
                    <a href="javascript:;" title="禁用" onclick="stop(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe60e;</i></a>
                    <?php } ?>
                    <a class="a-edit ml-5" <?php if($v['status'] == 0 || $v['status'] == 1) echo 'hidden';?>  href="javascript:;" title="编辑商品"  onclick="show('编辑商品','<?php echo url('goods/goodsSave',array('id' => $v['id']))?>','','','')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                    <a class="ml-5" href="javascript:;" title="删除动态"  onclick="del(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                    <a class="a-price ml-5" <?php if($v['status'] == 0 || $v['status'] == 1 || $flag) echo 'hidden';?> href="javascript:;" title="修改价格"  onclick="show('修改价格','<?php echo url('goods/price',array('id' => $v['id']))?>','','350','200')" style="text-decoration:none">￥</a>
                    <a <?php if($v['type_id'] != 1 || $v['status'] == 1) echo 'hidden';?> class="a-price ml-5" href="javascript:;" title="套餐管理"  onclick="show('套餐管理','<?php echo url('goods/combo',array('id' => $v['id']))?>','','','')" style="text-decoration:none"><i class="Hui-iconfont">&#xe63c;</i></a>
                </td>
			</tr>
		<?php endforeach;?>
        <?php if(empty($list)):?>
        <tr class="text-l"><td colspan="20">没有找到匹配的记录</td></tr>
        <?php endif;?>
		</tbody>
	</table>
	</div>
	<span class="r pages mt-10"><?php echo $page?></span>
</div>
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/js/layer.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/static/admin/lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
function nopass(obj,id) {
    layer.confirm('确认审核拒绝吗？', function (index) {
        $.ajax({
            type: 'post',
            url: "<?php echo url('goods/nopass')?>",
            data: {"id": id},
            success: function (data) {
                if (typeof data === 'string') {
                    data = jQuery.parseJSON(data);
                }
                if (data.code == 0) {
                    $(obj).parents("tr").find(".td-manage a").html();
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-warning radius">未通过</span>');
                    $(obj).parents("tr").find(".td-manage #pass").hide();
                    $(obj).remove();
                    layer.msg('已拒绝！', {icon: 7, time: 1000});
                } else {
                    layer.msg(data.msg, {icon: 5, time: 1000});
                }
            }
        });
    });
}

function pass(obj,id){
    layer.confirm('确认审核通过吗？',function(index){
        $.ajax({
            type:'post',
            url:"<?php echo url('goods/pass')?>",
            data:{"id":id},
            success:function(data){
                if(typeof data === 'string'){
                    data = jQuery.parseJSON(data);
                }
                if(data.code == 0){
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="stop(this,'+id+')" href="javascript:;" title="禁用"><i class="Hui-iconfont">&#xe60e;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
                    $(obj).parents("tr").find(".td-manage #nopass").hide();
                    $(obj).parents("tr").find(".td-manage .a-edit,.a-price").show();
                    $(obj).remove();
                    layer.msg('已通过！',{icon: 1,time:1000});
                }else{
                    layer.msg(data.msg,{icon:5,time:1000});
                }
            }
        });
    });
}

/*停用*/
function stop(obj,id){
	layer.confirm('确认要禁用吗？',function(index){
		$.ajax({
			type:'post',
			url:"<?php echo url('goods/stop')?>",
			data:{"id":id},
			success:function(data){
				if(typeof data === 'string'){
					data = jQuery.parseJSON(data);
				}
				if(data.code == 0){
					$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="start(this,'+id+')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe605;</i></a>');
					$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已禁用</span>');
					$(obj).remove();
					layer.msg('已禁用！',{icon: 7,time:1000});
				}else{
					layer.msg(data.msg,{icon:5,time:1000});
				}
			}
		});
	});
}

/*启用*/
function start(obj,id){
	layer.confirm('确认要启用吗？',function(index){
		$.ajax({
			type:'post',
			url:"<?php echo url('goods/start')?>",
			data:{"id":id},
			success:function(data){
				if(typeof data === 'string'){
					data = jQuery.parseJSON(data);
				}
				if(data.code == 0){
					$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="stop(this,'+id+')" href="javascript:;" title="禁用"><i class="Hui-iconfont">&#xe60e;</i></a>');
					$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
					$(obj).remove();
					layer.msg('已启用！',{icon: 1,time:1000});
				}else{
					layer.msg(data.msg,{icon:5,time:1000});
				}
			}
		});
	});
}

/*删除*/
function del(obj,id){
    layer.confirm('删除须谨慎，确认要删除吗？',function(index){
        $.ajax({
            type:'post',
            url:"<?php echo url('goods/goodsDel')?>",
            data:{"id":id},
            success:function(data){
                if(typeof data === 'string'){
                    data = jQuery.parseJSON(data);
                }
                if(data.code == 0){
                    $(obj).parents("tr").remove();
                    layer.msg(data.msg,{icon:1,time:1000});
                }else{
                    layer.msg(data.msg,{icon:5,time:1000});
                }
            }
        });
    });
}

/*详情*/
function show(title,url,id,w,h){
    layer_show(title,url,w,h);
}
</script>
</body>
</html>